﻿using System;
using System.Windows.Forms;

namespace StoCombatLogHUD
{
#if WINDOWS || LINUX
	/// <summary>
	/// The main programm code.
	/// </summary>
	public static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		private static void Main()
		{
			HandleAllExceptions(
				() =>
					{
						using (var game = new Main())
							game.Run();
					});
		}

		/// <summary>
		/// Handles all exceptions.
		/// NOTE: This is just here as a last resort if exceptions cannot be displayed in the UI.
		/// </summary>
		/// <param name="action">The action.</param>
		private static void HandleAllExceptions(Action action)
		{
#if DEBUG
			action();
			return;
#endif
			try
			{
				action();
			}
			catch (Exception ex)
			{
				MessageBox.Show("An Exception Occured: \n\n" + ex.Message);
			}
		}
#endif
	}
}
